$TITLE ('PL/M-51 TO RTX-51 V5.0 INTERFACE')
$SYMBOLS
$NOXREF
$NOCOND
$NOMOD51
$NORB
$PAGELENGTH(80) PAGEWIDTH(110)
;************************************************************************
;*									*
;*    R T X - 5 1  :   PL/M-51 TO RTX-51 V5.0 INTERFACE FILE 1          *
;*							     		*
;*----------------------------------------------------------------------*
;*                                                                      *
;*    Filename     :   RTXPLM1.A51                                      *
;*    Language     :   Keil A-51                                        *
;*    Dev. system  :   Keil uVision2                                    *
;*    Targetsystem :   Any system based upon 8051 up                    *
;*                                                                      *
;*    Purpose      :   Implements the first part of the PL/M-51 to      *
;*                     RTX-51 V5.xx Interface. This Interface is        *
;*                     dedicated for special purposes (Bitbus-Software) *
;*								     	*
;*----------------------------------------------------------------------*
;* Rev. |  Released   | Programmer    | Comments                        *
;*----------------------------------------------------------------------*
;* 0.1  |  12.11.1991 | Th. Fischler  | Module creation                 *
;*      |  29.06.1992 |               | oi_set/reset_masks added        *
;* 5.00 | 20.10.1994  | E. Glatz      | Release 5.00                    *
;* 7.00 | 13.11.2001  | T. Mueller    | Release 7.00, entry             *
;*      |             |               | 'p_os_wait1' removed            *
;************************************************************************
;*    Copyright 1991 .. 2001 METTLER  &  FUCHS  AG,  CH-8953 Dietikon   *
;************************************************************************


;*----------------------------------------------------------------------*
;*	I M P O R T S
;*----------------------------------------------------------------------*


EXTRN DATA     (?RTX_IE)      ; Interrupt-mask variable from RTXCONF.A51

; RTX-51 V4.xx system-functions
EXTRN   CODE (_os_start_system)
EXTRN   CODE (_os_create_task)
EXTRN   CODE (_os_delete_task)
EXTRN   CODE (os_running_task_id)
EXTRN   CODE (_os_wait)
EXTRN   CODE (_os_wait2)
EXTRN   CODE (_os_send_message)
EXTRN   CODE (_os_send_signal)
EXTRN   CODE (_os_clear_signal)
EXTRN   CODE (_os_set_slice)
EXTRN	CODE (_os_attach_interrupt)
EXTRN   CODE (_os_detach_interrupt)
EXTRN   CODE (_oi_set_int_masks)
EXTRN   CODE (_oi_reset_int_masks)


;*----------------------------------------------------------------------*
;*	E X P O R T S
;*----------------------------------------------------------------------*

PUBLIC  ?p_os_start_system?BYTE
PUBLIC	p_os_start_system
PUBLIC  ?p_os_create_task?BYTE
PUBLIC	p_os_create_task
PUBLIC  ?p_os_delete_task?BYTE
PUBLIC	p_os_delete_task
PUBLIC  p_os_running_task_id
PUBLIC  ?p_os_wait?BYTE
PUBLIC	p_os_wait
PUBLIC  ?p_os_wait2?BYTE
PUBLIC	p_os_wait2
PUBLIC  ?p_os_send_signal?BYTE
PUBLIC	p_os_send_signal
PUBLIC	?p_os_send_message?BYTE
PUBLIC	p_os_send_message
PUBLIC  ?p_os_clear_signal?BYTE
PUBLIC	p_os_clear_signal
PUBLIC  ?p_os_set_slice?BYTE
PUBLIC	p_os_set_slice
PUBLIC  ?p_os_attach_interrupt?BYTE
PUBLIC	p_os_attach_interrupt
PUBLIC  ?p_os_detach_interrupt?BYTE
PUBLIC	p_os_detach_interrupt
PUBLIC  ?p_oi_set_int_masks?BYTE
PUBLIC  p_oi_set_int_masks
PUBLIC  ?p_oi_reset_int_masks?BYTE
PUBLIC  p_oi_reset_int_masks


;*----------------------------------------------------------------------*
;*      S E G M E N T   D E F I N I T I O N S
;*----------------------------------------------------------------------*

; One Segment for all Code and Data in this File
?RTX?PLM2CINTF_CODE?RTXPLM1             SEGMENT CODE
?RTX?PLM2CINTF_DATA?RTXPLM1             SEGMENT DATA


;*----------------------------------------------------------------------*
;*      D A T A   D E F I N I T I O N S
;*----------------------------------------------------------------------*

; PL/M-51 compatible Parameter area in DATA-memory

        RSEG  ?RTX?PLM2CINTF_DATA?RTXPLM1
?p_os_start_system?BYTE:
task_number?00:		DS  1

                        ORG 0
?p_os_create_task?BYTE:
task_number?10:		DS  1

                        ORG 0
?p_os_delete_task?BYTE:
task_number?20:		DS  1

                        ORG 0
?p_os_wait2?BYTE:
event_selector?100:	DS  1
timeout?100:		DS  1

                        ORG 0
?p_os_send_message?BYTE:
mailbox?110:		DS  1
message?110:		DS  2
timeout?110:		DS  1

                        ORG 0
?p_os_send_signal?BYTE:
task_number?120:        DS  1

                        ORG 0
?p_os_clear_signal?BYTE:
task_number?130:        DS  1

                        ORG 0
?p_os_set_slice?BYTE:
timeslice?140:		DS  2

                        ORG 0
?p_os_attach_interrupt?BYTE:
interrupt_nbr?40:	DS  1

                        ORG 0
?p_os_detach_interrupt?BYTE:
interrupt_nbr?50:	DS  1

                        ORG 0
?p_oi_set_int_masks?BYTE:
ien0?260:		DS  1
ien1?260:		DS  1
ien2?260:		DS  1

                        ORG 0
?p_oi_reset_int_masks?BYTE:
ien0?270:		DS  1
ien1?270:		DS  1
ien2?270:		DS  1

                        ORG 0      ; The greatest Parameter-field in this
?p_os_wait?BYTE:                   ; Segment must be the last !
event_selector?80:      DS  1      ; (for proper segment-size allocation
timeout?80:             DS  1      ; by BL-51)
message?80:		DS  2



;*----------------------------------------------------------------------*
;*      P R O C E D U R E   D E F I N I T I O N S
;*----------------------------------------------------------------------*

;
;
; alien signed char p_os_start_system (unsigned char task_number)
        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_os_start_system:
; {
                        ; SOURCE LINE # 68
;    return os_start_system (task_number);
			; SOURCE LINE # 69
	MOV  	R7,task_number?00
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   _os_start_system
	MOV  	A,R7
; }
			; SOURCE LINE # 70
?C0001:
	RET  	
; END OF p_os_start_system

; 
; 
; alien signed char p_os_create_task (unsigned char task_number)

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_os_create_task:
			; SOURCE LINE # 73
; {
			; SOURCE LINE # 74
;    return os_create_task (task_number);
			; SOURCE LINE # 75
	MOV  	R7,task_number?10
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   _os_create_task
	MOV  	A,R7
; }
			; SOURCE LINE # 76
?C0002:
	RET  	
; END OF p_os_create_task

; 
; 
; alien signed char p_os_delete_task (unsigned char task_number)

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_os_delete_task:
			; SOURCE LINE # 79
; {
			; SOURCE LINE # 80
;    return os_delete_task (task_number);
			; SOURCE LINE # 81
	MOV  	R7,task_number?20
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   _os_delete_task
	MOV  	A,R7
; }
			; SOURCE LINE # 82
?C0003:
	RET  	
; END OF p_os_delete_task

;
; 
; alien unsigned char p_os_running_task_id (void)

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_os_running_task_id:
			; SOURCE LINE # 85
; {
			; SOURCE LINE # 86
;    return os_running_task_id ();
			; SOURCE LINE # 87
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   os_running_task_id
	MOV  	A,R7
; }
			; SOURCE LINE # 88
?C0004:
	RET  	
; END OF p_os_running_task_id

;
; 
; alien signed char p_os_wait (unsigned char event_selector,

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_os_wait:
			; SOURCE LINE # 115
;                              unsigned char timeout,
;                              unsigned int xdata *message)
; {
			; SOURCE LINE # 118
;    return os_wait (event_selector, timeout, message);
			; SOURCE LINE # 119
	MOV  	R7,event_selector?80
	MOV  	R5,timeout?80
	MOV  	R3,message?80+01H
	MOV  	R2,message?80
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   _os_wait
	MOV  	A,R7
; }
			; SOURCE LINE # 120
?C0009:
	RET  	
; END OF p_os_wait

; 
; 
; alien signed char p_os_wait2 (unsigned char event_selector,

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_os_wait2:
			; SOURCE LINE # 129
;                               unsigned char timeout)
; {
			; SOURCE LINE # 131
;    return os_wait2 (event_selector, timeout);
			; SOURCE LINE # 132
	MOV  	R7,event_selector?100
	MOV  	R5,timeout?100
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   _os_wait2
	MOV  	A,R7
; }
			; SOURCE LINE # 133
?C0011:
	RET  	
; END OF p_os_wait2

;
; 
; alien signed char p_os_send_message (unsigned char mailbox,

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_os_send_message:
			; SOURCE LINE # 136
;                                      unsigned int message,
;                                      unsigned char timeout)
; {
			; SOURCE LINE # 139
;    return os_send_message (mailbox, message, timeout);
			; SOURCE LINE # 140
	MOV  	R7,mailbox?110
	MOV  	R5,message?110+01H
	MOV  	R4,message?110
	MOV  	R3,timeout?110
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   _os_send_message
	MOV  	A,R7
; }
			; SOURCE LINE # 141
?C0012:
	RET  	
; END OF p_os_send_message

; 
; 
; alien signed char p_os_send_signal (unsigned char task_number)

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_os_send_signal:
			; SOURCE LINE # 144
; {
			; SOURCE LINE # 145
;    return os_send_signal (task_number);
			; SOURCE LINE # 146
	MOV  	R7,task_number?120
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   _os_send_signal
	MOV  	A,R7
; }
			; SOURCE LINE # 147
?C0013:
	RET  	
; END OF p_os_send_signal

; 
; 
; alien signed char p_os_clear_signal (unsigned char task_number)

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_os_clear_signal:
			; SOURCE LINE # 150
; {
			; SOURCE LINE # 151
;    return os_clear_signal (task_number);
			; SOURCE LINE # 152
	MOV  	R7,task_number?130
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   _os_clear_signal
	MOV  	A,R7
; }
			; SOURCE LINE # 153
?C0014:
	RET  	
; END OF p_os_clear_signal

;
; 
; alien signed char p_os_set_slice (unsigned int timeslice)

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_os_set_slice:
			; SOURCE LINE # 156
; {
			; SOURCE LINE # 157
;    return os_set_slice (timeslice);
			; SOURCE LINE # 158
	MOV  	R7,timeslice?140+01H
	MOV  	R6,timeslice?140
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   _os_set_slice
	MOV  	A,R7
; }
			; SOURCE LINE # 159
?C0015:
	RET  	
; END OF p_os_set_slice

;
; 
; alien signed char p_os_attach_interrupt (unsigned char interrupt_nbr)

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_os_attach_interrupt:
			; SOURCE LINE # 91
; {
			; SOURCE LINE # 92
;    return os_attach_interrupt (interrupt_nbr);
			; SOURCE LINE # 93
	MOV  	R7,interrupt_nbr?40
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   _os_attach_interrupt
	MOV  	A,R7
; }
			; SOURCE LINE # 94
?C0005:
	RET  	
; END OF p_os_attach_interrupt

; 
; 
; alien signed char p_os_detach_interrupt (unsigned char interrupt_nbr)

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_os_detach_interrupt:
			; SOURCE LINE # 97
; {
			; SOURCE LINE # 98
;    return os_detach_interrupt (interrupt_nbr);
			; SOURCE LINE # 99
	MOV  	R7,interrupt_nbr?50
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   _os_detach_interrupt
	MOV  	A,R7
; }
			; SOURCE LINE # 100
?C0006:
	RET  	
; END OF p_os_detach_interrupt

;
; 
; alien signed char p_oi_set_int_masks (unsigned char ien0,

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_oi_set_int_masks:
			; SOURCE LINE # 237
;                                      unsigned char ien1,
;                                      unsigned char ien2)
; {
			; SOURCE LINE # 240
;    return oi_set_int_masks (ien0, ien1, ien2);
			; SOURCE LINE # 241
	MOV  	R7,ien0?260
	MOV  	R5,ien1?260
	MOV  	R3,ien2?260
        SETB    ?RTX_IE.7                   ; enable all Interrupts
	LCALL	_oi_set_int_masks
	MOV  	A,R7
; }
			; SOURCE LINE # 242
?C0027:
	RET  	
; END OF p_oi_set_int_masks

; 
; 
; alien signed char p_oi_reset_int_masks (unsigned char ien0,

        RSEG  ?RTX?PLM2CINTF_CODE?RTXPLM1
p_oi_reset_int_masks:
			; SOURCE LINE # 245
;                                        unsigned char ien1,
;                                        unsigned char ien2)
; {
			; SOURCE LINE # 248
;    return oi_reset_int_masks (ien0, ien1, ien2);
			; SOURCE LINE # 249
	MOV  	R7,ien0?270
	MOV  	R5,ien1?270
	MOV  	R3,ien2?270
        SETB    ?RTX_IE.7                   ; enable all Interrupts
        LCALL   _oi_reset_int_masks
	MOV  	A,R7
; }
			; SOURCE LINE # 250
?C0028:
	RET  	
; END OF p_oi_reset_int_masks


;
;   END OF MODULE
;
	END
